﻿using System;
using Moonlite.UI.Shell.Controls;
using Moonlite.Services.CodeCompletion;

namespace Moonlite.Data.Configuration.Implementation
{
    internal sealed class MoonliteTextEditorConfigurationElement : ConfigurationElement
    {
        public static readonly Type Type = typeof(MoonliteTextEditorConfigurationElement);

        private bool parseOnSave;
        private string fontName;
        private int fontSize;
        private bool allowDynamicParsing;
        private int dynamicParseInterval;
        private bool convertTabsToSpaces;
        private int tabSize;

        public override string Name
        {
            get { return "Text Editor"; }
        }

        [ConfigurationProperty(false, typeof(TextEditor), "ParseOnSave")]
        public bool ParseOnSave
        {
            get { return parseOnSave; }
            set
            {
                parseOnSave = value;
                RaisePropertyChangedEvent("ParseOnSave");
            }
        }

        [ConfigurationProperty("Consolas", typeof(TextEditor), "FontName")]
        public string FontName
        {
            get { return fontName; }
            set
            {
                fontName = value;
                RaisePropertyChangedEvent("FontName");
            }
        }

        [ConfigurationProperty(10, typeof(TextEditor), "FontSize")]
        public int FontSize
        {
            get { return fontSize; }
            set
            {
                fontSize = value;
                RaisePropertyChangedEvent("FontSize");
            }
        }

        [ConfigurationProperty(true, typeof(DynamicSyntaxCheckingScheduler), "Enabled")]
        public bool AllowDynamicParsing
        {
            get { return allowDynamicParsing; }
            set
            {
                allowDynamicParsing = value;
                RaisePropertyChangedEvent("AllowDynamicParsing");
            }
        }

        [ConfigurationProperty(1000, typeof(DynamicSyntaxCheckingScheduler), "Interval")]
        public int DynamicParseInterval
        {
            get { return dynamicParseInterval; }
            set
            {
                dynamicParseInterval = value;
                RaisePropertyChangedEvent("DynamicParseInterval");
            }
        }

        [ConfigurationProperty(false, typeof(TextEditor), "ConvertTabsToSpaces")]
        public bool ConvertTabsToSpaces
        {
            get { return convertTabsToSpaces; }
            set
            {
                convertTabsToSpaces = value;
                RaisePropertyChangedEvent("ConvertTabsToSpaces");
            }
        }

        [ConfigurationProperty(4, typeof(TextEditor), "TabSize")]
        public int TabSize
        {
            get { return tabSize; }
            set
            {
                tabSize = value;
                RaisePropertyChangedEvent("TabSize");
            }
        }
    }
}
